package config

import (
	L "../app/logic"
	"encoding/json"
	"fmt"
)

type NoMatch struct {
	code     int
	msg      string
	data     []string
}

func Router(name string) string{

	router_list := map[string]func() string{
		"/home" : L.Test2,
		"/index": L.Test2,
		"/test" : L.Test3,
	}

	if _, ok := router_list[name] ; ok {
		return router_list[name]()
	}else {
		group := NoMatch{
			code:     400,
			msg:      "There is noting",
			data:      []string{"Crimson", "Red", "Ruby", "Maroon"},
		}
		b, err := json.Marshal(group)
		if err != nil {
			fmt.Println("error:", err)
		}
		return string(b)
	}
	return "1";
}
